"use strict";
"undefined" != typeof globalThis
  ? globalThis
  : "undefined" != typeof window
  ? window
  : "undefined" != typeof global
  ? global
  : "undefined" != typeof self && self;
function e(e) {
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default")
    ? e.default
    : e;
}
var t = { exports: {} },
  r = e(
    (t.exports = (function (e) {
      function t(n) {
        if (r[n]) return r[n].exports;
        var o = (r[n] = { exports: {}, id: n, loaded: !1 });
        return (
          e[n].call(o.exports, o, o.exports, t), (o.loaded = !0), o.exports
        );
      }
      var r = {};
      return (t.m = e), (t.c = r), (t.p = ""), t(0);
    })([
      function (e, t, r) {
        e.exports = r(1);
      },
      function (e, t, r) {
        function n(e) {
          var t = new a(e),
            r = s(a.prototype.request, t);
          return o.extend(r, a.prototype, t), o.extend(r, t), r;
        }
        var o = r(2),
          s = r(3),
          a = r(5),
          i = r(6),
          u = n(i);
        (u.Axios = a),
          (u.create = function (e) {
            return n(o.merge(i, e));
          }),
          (u.Cancel = r(22)),
          (u.CancelToken = r(23)),
          (u.isCancel = r(19)),
          (u.all = function (e) {
            return Promise.all(e);
          }),
          (u.spread = r(24)),
          (e.exports = u),
          (e.exports.default = u);
      },
      function (e, t, r) {
        function n(e) {
          return "[object Array]" === C.call(e);
        }
        function o(e) {
          return "[object ArrayBuffer]" === C.call(e);
        }
        function s(e) {
          return "undefined" != typeof FormData && e instanceof FormData;
        }
        function a(e) {
          return "undefined" != typeof ArrayBuffer && ArrayBuffer.isView
            ? ArrayBuffer.isView(e)
            : e && e.buffer && e.buffer instanceof ArrayBuffer;
        }
        function i(e) {
          return "string" == typeof e;
        }
        function u(e) {
          return "number" == typeof e;
        }
        function c(e) {
          return void 0 === e;
        }
        function f(e) {
          return null !== e && "object" == typeof e;
        }
        function p(e) {
          return "[object Date]" === C.call(e);
        }
        function l(e) {
          return "[object File]" === C.call(e);
        }
        function d(e) {
          return "[object Blob]" === C.call(e);
        }
        function h(e) {
          return "[object Function]" === C.call(e);
        }
        function m(e) {
          return f(e) && h(e.pipe);
        }
        function y(e) {
          return (
            "undefined" != typeof URLSearchParams &&
            e instanceof URLSearchParams
          );
        }
        function g(e) {
          return e.replace(/^\s*/, "").replace(/\s*$/, "");
        }
        function v() {
          return (
            ("undefined" == typeof navigator ||
              "ReactNative" !== navigator.product) &&
            "undefined" != typeof window &&
            "undefined" != typeof document
          );
        }
        function w(e, t) {
          if (null != e)
            if (("object" != typeof e && (e = [e]), n(e)))
              for (var r = 0, o = e.length; r < o; r++)
                t.call(null, e[r], r, e);
            else
              for (var s in e)
                Object.prototype.hasOwnProperty.call(e, s) &&
                  t.call(null, e[s], s, e);
        }
        function x() {
          function e(e, r) {
            "object" == typeof t[r] && "object" == typeof e
              ? (t[r] = x(t[r], e))
              : (t[r] = e);
          }
          for (var t = {}, r = 0, n = arguments.length; r < n; r++)
            w(arguments[r], e);
          return t;
        }
        function b(e, t, r) {
          return (
            w(t, function (t, n) {
              e[n] = r && "function" == typeof t ? j(t, r) : t;
            }),
            e
          );
        }
        var j = r(3),
          R = r(4),
          C = Object.prototype.toString;
        e.exports = {
          isArray: n,
          isArrayBuffer: o,
          isBuffer: R,
          isFormData: s,
          isArrayBufferView: a,
          isString: i,
          isNumber: u,
          isObject: f,
          isUndefined: c,
          isDate: p,
          isFile: l,
          isBlob: d,
          isFunction: h,
          isStream: m,
          isURLSearchParams: y,
          isStandardBrowserEnv: v,
          forEach: w,
          merge: x,
          extend: b,
          trim: g,
        };
      },
      function (e, t) {
        e.exports = function (e, t) {
          return function () {
            for (var r = new Array(arguments.length), n = 0; n < r.length; n++)
              r[n] = arguments[n];
            return e.apply(t, r);
          };
        };
      },
      function (e, t) {
        /*!
         * Determine if an object is a Buffer
         *
         * @author   Feross Aboukhadijeh <https://feross.org>
         * @license  MIT
         */
        e.exports = function (e) {
          return (
            null != e &&
            null != e.constructor &&
            "function" == typeof e.constructor.isBuffer &&
            e.constructor.isBuffer(e)
          );
        };
      },
      function (e, t, r) {
        function n(e) {
          (this.defaults = e),
            (this.interceptors = { request: new a(), response: new a() });
        }
        var o = r(6),
          s = r(2),
          a = r(16),
          i = r(17);
        (n.prototype.request = function (e) {
          "string" == typeof e &&
            (e = s.merge({ url: arguments[0] }, arguments[1])),
            ((e = s.merge(o, { method: "get" }, this.defaults, e)).method =
              e.method.toLowerCase());
          var t = [i, void 0],
            r = Promise.resolve(e);
          for (
            this.interceptors.request.forEach(function (e) {
              t.unshift(e.fulfilled, e.rejected);
            }),
              this.interceptors.response.forEach(function (e) {
                t.push(e.fulfilled, e.rejected);
              });
            t.length;

          )
            r = r.then(t.shift(), t.shift());
          return r;
        }),
          s.forEach(["delete", "get", "head", "options"], function (e) {
            n.prototype[e] = function (t, r) {
              return this.request(s.merge(r || {}, { method: e, url: t }));
            };
          }),
          s.forEach(["post", "put", "patch"], function (e) {
            n.prototype[e] = function (t, r, n) {
              return this.request(
                s.merge(n || {}, { method: e, url: t, data: r })
              );
            };
          }),
          (e.exports = n);
      },
      function (e, t, r) {
        function n(e, t) {
          !s.isUndefined(e) &&
            s.isUndefined(e["Content-Type"]) &&
            (e["Content-Type"] = t);
        }
        function o() {
          var e;
          return (
            ("undefined" != typeof XMLHttpRequest ||
              "undefined" != typeof process) &&
              (e = r(8)),
            e
          );
        }
        var s = r(2),
          a = r(7),
          i = { "Content-Type": "application/x-www-form-urlencoded" },
          u = {
            adapter: o(),
            transformRequest: [
              function (e, t) {
                return (
                  a(t, "Content-Type"),
                  s.isFormData(e) ||
                  s.isArrayBuffer(e) ||
                  s.isBuffer(e) ||
                  s.isStream(e) ||
                  s.isFile(e) ||
                  s.isBlob(e)
                    ? e
                    : s.isArrayBufferView(e)
                    ? e.buffer
                    : s.isURLSearchParams(e)
                    ? (n(t, "application/x-www-form-urlencoded;charset=utf-8"),
                      e.toString())
                    : s.isObject(e)
                    ? (n(t, "application/json;charset=utf-8"),
                      JSON.stringify(e))
                    : e
                );
              },
            ],
            transformResponse: [
              function (e) {
                if ("string" == typeof e)
                  try {
                    e = JSON.parse(e);
                  } catch (e) {}
                return e;
              },
            ],
            timeout: 0,
            xsrfCookieName: "XSRF-TOKEN",
            xsrfHeaderName: "X-XSRF-TOKEN",
            maxContentLength: -1,
            validateStatus: function (e) {
              return e >= 200 && e < 300;
            },
            headers: {
              common: { Accept: "application/json, text/plain, */*" },
            },
          };
        s.forEach(["delete", "get", "head"], function (e) {
          u.headers[e] = {};
        }),
          s.forEach(["post", "put", "patch"], function (e) {
            u.headers[e] = s.merge(i);
          }),
          (e.exports = u);
      },
      function (e, t, r) {
        var n = r(2);
        e.exports = function (e, t) {
          n.forEach(e, function (r, n) {
            n !== t &&
              n.toUpperCase() === t.toUpperCase() &&
              ((e[t] = r), delete e[n]);
          });
        };
      },
      function (e, t, r) {
        var n = r(2),
          o = r(9),
          s = r(12),
          a = r(13),
          i = r(14),
          u = r(10);
        e.exports = function (e) {
          return new Promise(function (t, c) {
            var f = e.data,
              p = e.headers;
            n.isFormData(f) && delete p["Content-Type"];
            var l = new XMLHttpRequest();
            if (e.auth) {
              var d = e.auth.username || "",
                h = e.auth.password || "";
              p.Authorization = "Basic " + btoa(d + ":" + h);
            }
            if (
              (l.open(
                e.method.toUpperCase(),
                s(e.url, e.params, e.paramsSerializer),
                !0
              ),
              (l.timeout = e.timeout),
              (l.onreadystatechange = function () {
                if (
                  l &&
                  4 === l.readyState &&
                  (0 !== l.status ||
                    (l.responseURL && 0 === l.responseURL.indexOf("file:")))
                ) {
                  var r =
                      "getAllResponseHeaders" in l
                        ? a(l.getAllResponseHeaders())
                        : null,
                    n = {
                      data:
                        e.responseType && "text" !== e.responseType
                          ? l.response
                          : l.responseText,
                      status: l.status,
                      statusText: l.statusText,
                      headers: r,
                      config: e,
                      request: l,
                    };
                  o(t, c, n), (l = null);
                }
              }),
              (l.onerror = function () {
                c(u("Network Error", e, null, l)), (l = null);
              }),
              (l.ontimeout = function () {
                c(
                  u(
                    "timeout of " + e.timeout + "ms exceeded",
                    e,
                    "ECONNABORTED",
                    l
                  )
                ),
                  (l = null);
              }),
              n.isStandardBrowserEnv())
            ) {
              var m = r(15),
                y =
                  (e.withCredentials || i(e.url)) && e.xsrfCookieName
                    ? m.read(e.xsrfCookieName)
                    : void 0;
              y && (p[e.xsrfHeaderName] = y);
            }
            if (
              ("setRequestHeader" in l &&
                n.forEach(p, function (e, t) {
                  void 0 === f && "content-type" === t.toLowerCase()
                    ? delete p[t]
                    : l.setRequestHeader(t, e);
                }),
              e.withCredentials && (l.withCredentials = !0),
              e.responseType)
            )
              try {
                l.responseType = e.responseType;
              } catch (t) {
                if ("json" !== e.responseType) throw t;
              }
            "function" == typeof e.onDownloadProgress &&
              l.addEventListener("progress", e.onDownloadProgress),
              "function" == typeof e.onUploadProgress &&
                l.upload &&
                l.upload.addEventListener("progress", e.onUploadProgress),
              e.cancelToken &&
                e.cancelToken.promise.then(function (e) {
                  l && (l.abort(), c(e), (l = null));
                }),
              void 0 === f && (f = null),
              l.send(f);
          });
        };
      },
      function (e, t, r) {
        var n = r(10);
        e.exports = function (e, t, r) {
          var o = r.config.validateStatus;
          r.status && o && !o(r.status)
            ? t(
                n(
                  "Request failed with status code " + r.status,
                  r.config,
                  null,
                  r.request,
                  r
                )
              )
            : e(r);
        };
      },
      function (e, t, r) {
        var n = r(11);
        e.exports = function (e, t, r, o, s) {
          var a = new Error(e);
          return n(a, t, r, o, s);
        };
      },
      function (e, t) {
        e.exports = function (e, t, r, n, o) {
          return (
            (e.config = t),
            r && (e.code = r),
            (e.request = n),
            (e.response = o),
            e
          );
        };
      },
      function (e, t, r) {
        function n(e) {
          return encodeURIComponent(e)
            .replace(/%40/gi, "@")
            .replace(/%3A/gi, ":")
            .replace(/%24/g, "$")
            .replace(/%2C/gi, ",")
            .replace(/%20/g, "+")
            .replace(/%5B/gi, "[")
            .replace(/%5D/gi, "]");
        }
        var o = r(2);
        e.exports = function (e, t, r) {
          if (!t) return e;
          var s;
          if (r) s = r(t);
          else if (o.isURLSearchParams(t)) s = t.toString();
          else {
            var a = [];
            o.forEach(t, function (e, t) {
              null != e &&
                (o.isArray(e) ? (t += "[]") : (e = [e]),
                o.forEach(e, function (e) {
                  o.isDate(e)
                    ? (e = e.toISOString())
                    : o.isObject(e) && (e = JSON.stringify(e)),
                    a.push(n(t) + "=" + n(e));
                }));
            }),
              (s = a.join("&"));
          }
          return s && (e += (-1 === e.indexOf("?") ? "?" : "&") + s), e;
        };
      },
      function (e, t, r) {
        var n = r(2),
          o = [
            "age",
            "authorization",
            "content-length",
            "content-type",
            "etag",
            "expires",
            "from",
            "host",
            "if-modified-since",
            "if-unmodified-since",
            "last-modified",
            "location",
            "max-forwards",
            "proxy-authorization",
            "referer",
            "retry-after",
            "user-agent",
          ];
        e.exports = function (e) {
          var t,
            r,
            s,
            a = {};
          return e
            ? (n.forEach(e.split("\n"), function (e) {
                if (
                  ((s = e.indexOf(":")),
                  (t = n.trim(e.substr(0, s)).toLowerCase()),
                  (r = n.trim(e.substr(s + 1))),
                  t)
                ) {
                  if (a[t] && o.indexOf(t) >= 0) return;
                  a[t] =
                    "set-cookie" === t
                      ? (a[t] ? a[t] : []).concat([r])
                      : a[t]
                      ? a[t] + ", " + r
                      : r;
                }
              }),
              a)
            : a;
        };
      },
      function (e, t, r) {
        var n = r(2);
        e.exports = n.isStandardBrowserEnv()
          ? (function () {
              function e(e) {
                var t = e;
                return (
                  r && (o.setAttribute("href", t), (t = o.href)),
                  o.setAttribute("href", t),
                  {
                    href: o.href,
                    protocol: o.protocol ? o.protocol.replace(/:$/, "") : "",
                    host: o.host,
                    search: o.search ? o.search.replace(/^\?/, "") : "",
                    hash: o.hash ? o.hash.replace(/^#/, "") : "",
                    hostname: o.hostname,
                    port: o.port,
                    pathname:
                      "/" === o.pathname.charAt(0)
                        ? o.pathname
                        : "/" + o.pathname,
                  }
                );
              }
              var t,
                r = /(msie|trident)/i.test(navigator.userAgent),
                o = document.createElement("a");
              return (
                (t = e(window.location.href)),
                function (r) {
                  var o = n.isString(r) ? e(r) : r;
                  return o.protocol === t.protocol && o.host === t.host;
                }
              );
            })()
          : function () {
              return !0;
            };
      },
      function (e, t, r) {
        var n = r(2);
        e.exports = n.isStandardBrowserEnv()
          ? {
              write: function (e, t, r, o, s, a) {
                var i = [];
                i.push(e + "=" + encodeURIComponent(t)),
                  n.isNumber(r) &&
                    i.push("expires=" + new Date(r).toGMTString()),
                  n.isString(o) && i.push("path=" + o),
                  n.isString(s) && i.push("domain=" + s),
                  !0 === a && i.push("secure"),
                  (document.cookie = i.join("; "));
              },
              read: function (e) {
                var t = document.cookie.match(
                  new RegExp("(^|;\\s*)(" + e + ")=([^;]*)")
                );
                return t ? decodeURIComponent(t[3]) : null;
              },
              remove: function (e) {
                this.write(e, "", Date.now() - 864e5);
              },
            }
          : {
              write: function () {},
              read: function () {
                return null;
              },
              remove: function () {},
            };
      },
      function (e, t, r) {
        function n() {
          this.handlers = [];
        }
        var o = r(2);
        (n.prototype.use = function (e, t) {
          return (
            this.handlers.push({ fulfilled: e, rejected: t }),
            this.handlers.length - 1
          );
        }),
          (n.prototype.eject = function (e) {
            this.handlers[e] && (this.handlers[e] = null);
          }),
          (n.prototype.forEach = function (e) {
            o.forEach(this.handlers, function (t) {
              null !== t && e(t);
            });
          }),
          (e.exports = n);
      },
      function (e, t, r) {
        function n(e) {
          e.cancelToken && e.cancelToken.throwIfRequested();
        }
        var o = r(2),
          s = r(18),
          a = r(19),
          i = r(6),
          u = r(20),
          c = r(21);
        e.exports = function (e) {
          return (
            n(e),
            e.baseURL && !u(e.url) && (e.url = c(e.baseURL, e.url)),
            (e.headers = e.headers || {}),
            (e.data = s(e.data, e.headers, e.transformRequest)),
            (e.headers = o.merge(
              e.headers.common || {},
              e.headers[e.method] || {},
              e.headers || {}
            )),
            o.forEach(
              ["delete", "get", "head", "post", "put", "patch", "common"],
              function (t) {
                delete e.headers[t];
              }
            ),
            (e.adapter || i.adapter)(e).then(
              function (t) {
                return (
                  n(e), (t.data = s(t.data, t.headers, e.transformResponse)), t
                );
              },
              function (t) {
                return (
                  a(t) ||
                    (n(e),
                    t &&
                      t.response &&
                      (t.response.data = s(
                        t.response.data,
                        t.response.headers,
                        e.transformResponse
                      ))),
                  Promise.reject(t)
                );
              }
            )
          );
        };
      },
      function (e, t, r) {
        var n = r(2);
        e.exports = function (e, t, r) {
          return (
            n.forEach(r, function (r) {
              e = r(e, t);
            }),
            e
          );
        };
      },
      function (e, t) {
        e.exports = function (e) {
          return !(!e || !e.__CANCEL__);
        };
      },
      function (e, t) {
        e.exports = function (e) {
          return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e);
        };
      },
      function (e, t) {
        e.exports = function (e, t) {
          return t ? e.replace(/\/+$/, "") + "/" + t.replace(/^\/+/, "") : e;
        };
      },
      function (e, t) {
        function r(e) {
          this.message = e;
        }
        (r.prototype.toString = function () {
          return "Cancel" + (this.message ? ": " + this.message : "");
        }),
          (r.prototype.__CANCEL__ = !0),
          (e.exports = r);
      },
      function (e, t, r) {
        function n(e) {
          if ("function" != typeof e)
            throw new TypeError("executor must be a function.");
          var t;
          this.promise = new Promise(function (e) {
            t = e;
          });
          var r = this;
          e(function (e) {
            r.reason || ((r.reason = new o(e)), t(r.reason));
          });
        }
        var o = r(22);
        (n.prototype.throwIfRequested = function () {
          if (this.reason) throw this.reason;
        }),
          (n.source = function () {
            var e;
            return {
              token: new n(function (t) {
                e = t;
              }),
              cancel: e,
            };
          }),
          (e.exports = n);
      },
      function (e, t) {
        e.exports = function (e) {
          return function (t) {
            return e.apply(null, t);
          };
        };
      },
    ]))
  );
const n = {
  isUni: !1,
  default: { baseURL: "http://127.0.0.1:8080", timeout: 12e4 },
};
let o = () => {};
var s = {
  setUserConfig: function (e) {
    e && (o = e);
  },
  getConfig: function () {
    return Object.assign({}, n, o());
  },
};
let a = s.getConfig,
  i = r.create({ baseURL: a().default.baseURL, timeout: a().default.timeout });
i.interceptors.request.use(
  (e) => (
    (function (e) {
      "/" == e.url.slice(0, 1) && (e.url = e.url.slice(1));
      let t = e.url.split("/");
      const r = t[0];
      Object.keys(a()).some((e) => e === r)
        ? ((t[0] = ""), (e.url = t.join("/")), f(e, r))
        : f(e);
    })(e),
    u(e),
    a().isUni && (e.adapter = c),
    e
  ),
  (e) => Promise.reject(e)
),
  i.interceptors.response.use(
    (e) => e.data,
    (e) => (console.log("err" + e), Promise.reject(e))
  );
const u = (e) => {
    if ("get" === e.method && e.params) {
      let r = e.url + "?";
      for (const n of Object.keys(e.params)) {
        const o = e.params[n];
        var t = encodeURIComponent(n) + "=";
        if (null != o)
          if ("object" == typeof o)
            for (const e of Object.keys(o)) {
              r +=
                encodeURIComponent(n + "[" + e + "]") +
                "=" +
                encodeURIComponent(o[e]) +
                "&";
            }
          else r += t + encodeURIComponent(o) + "&";
      }
      (r = r.slice(0, -1)), (e.params = {}), (e.url = r);
    }
  },
  c = (e) => {
    try {
      uni;
    } catch {
      throw new Error("不要在非UNIAPP项目中配置 isUni 为 true");
    }
    return new Promise((t, r) => {
      const { headers: n, data: o, params: s } = e,
        a = { ...e, header: n };
      if (o || s)
        try {
          a.data = JSON.parse(o || s);
        } catch (e) {
          a.data = o || s;
        }
      uni.request({
        ...a,
        success(e) {
          t({ ...e, headers: e.header });
        },
        fail(e) {
          r({ ...e, headers: e.header });
        },
      });
    });
  };
function f(e, t = "default") {
  const r = a();
  (e.baseURL = r[t].baseURL),
    (e.timeout = r[t].timeout),
    r[t].headers && (e.headers = Object.assign(e.headers, r[t].headers));
}
function p(e, t) {
  return i({ url: e, method: "GET", params: t });
}
function l(e, t) {
  return i({ url: e, method: "post", data: t });
}
function d(e, t) {
  return i({ url: e, method: "put", data: t });
}
function h(e, t) {
  return i({ url: e, method: "delete", data: t });
}
var m = Object.freeze({ __proto__: null, del: h, get: p, post: l, put: d });
module.exports = (e) => (
  s.setUserConfig(e),
  {
    ...m,
    install(e) {
      (e.prototype.$get = p),
        (e.prototype.$post = l),
        (e.prototype.$put = d),
        (e.prototype.$del = h);
    },
  }
);
